import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class ShowDialog {
  static cupertinoDialog(
    BuildContext context, {
    String title = '',
    String content = '这是消息',
    String closeText = '取消',
    String sureText = '确定',
    required Function closeFunction,
    required Function sureFunction,
  }) {
    return showDialog(
        context: context,
        barrierDismissible: false,
        builder: (BuildContext context) {
          return CupertinoAlertDialog(
            title: title == '' ? null : Text(title),
            content: Column(
              children: <Widget>[
                SizedBox(
                  height: 10.w,
                ),
                Align(
                  child: Text(
                    content,
                    style:
                        TextStyle(fontSize: 15.sp, fontWeight: FontWeight.bold),
                  ),
                  alignment: Alignment(0, 0),
                ),
              ],
            ),
            actions: <Widget>[
              CupertinoDialogAction(
                child: Text("取消"),
                onPressed: () {
                  Navigator.pop(context);
                  closeFunction();
                },
              ),
              CupertinoDialogAction(
                child: Text("确定"),
                onPressed: () {
                  Navigator.pop(context);
                  sureFunction();
                },
              ),
            ],
          );
        });
  }
}
